#{extends 'noTab.html' /} #{set title: 'SuperSoft Search Results' /}


<title>Search Results</title>
<h4><a href="@{Application.index()}">Back to First Page</a></h4>
<br/>
<h4>You can filter search results by:</h4>
<a href = @{Application.filterByIdea(searchKeyWord)} class="standardLink"> Idea</a>
<a href = @{Application.filterByOrg(searchKeyWord)} class="standardLink"> Organization</a>
<a href = @{Application.filterByEntity(searchKeyWord)} class="standardLink"> Entity</a>
<a href = @{Application.filterByTopic(searchKeyWord)} class="standardLink"> Topic</a>
<a href = @{Application.filterByTopic(searchKeyWord)} class="standardLink"> Plan</a>

<br/><br/><br/>
<form action="@{Application.sortByRating()}" method="GET">
<input type  ="submit" value = "Order by Rating" ></input>
<input type = "hidden" value = "${searchKeyWord}"  name = "searchKeyWord"></input>
</form>

<form action="@{Application.sortByViews()}" method="GET">
<input type  ="submit" value = "Order by Number of Views" ></input>
<input type = "hidden" value = "${searchKeyWord}"  name = "searchKeyWord"></input>
</form>

<form action="@{Application.sortByRatingAsc()}" method="GET">
<input type  ="submit" value = "Order by Rating Ascendingly" ></input>
<input type = "hidden" value = "${searchKeyWord}"  name = "searchKeyWord"></input>
</form>

<form action="@{Application.sortByViewsAsc()}" method="GET">
<input type  ="submit" value = "Order by Number of Views Ascendingly" ></input>
<input type = "hidden" value = "${searchKeyWord}"  name = "searchKeyWord"></input>
</form>

<br/><br/>
<h3>Results Sorted By Rating</h3>
<br/>
<h4>Ideas by title</h4>
#{list items:ideaByTitleResult, as:'product'}
    
#{if !(product.isDraft) && (!(product.topic.entity.organization.isSecret()) || product.topic.entity.organization.isMember(id))}
   <a href = @{Browse.viewIdea(product.id)} class="standardLink"> ${product.title}</a><br/>
#{/if}

#{/list}
#{else}
    No titles match your key word
#{/else}

<br/><br/>

<h4>Ideas by tag</h4>
#{list items:ideaByTagResult, as:'product'}
    
#{if !(product.isDraft) && (!(product.topic.entity.organization.isSecret()) || product.topic.entity.organization.isMember(id))}
   <a href = @{Browse.viewIdea(product.id)} class="standardLink"> ${product.title}</a><br/>
#{/if}

#{/list}
#{else}
    No ideas are related to your key word
#{/else}

<br/><br/>

<h4>Organizations by name</h4>

#{list items:orgByNameResult, as:'product'}
    

   <a href = @{Browse.viewOrganization(product.id)} class="standardLink"> ${product.name}</a><br/>

#{/list}
#{else}
    No organizations match your key word
#{/else}

<br/><br/>

<h4>Entities by name</h4>
#{list items:entityByNameResult, as:'product'}
    
#{if !(product.organization.isSecret()) || product.organization.isMember(id)}
   <a href = @{Browse.viewEntity(product.id)} class="standardLink"> ${product.name}</a><br/>
#{/if}
#{else}
     secret : ${product.name} <br>
#{/else}
#{/list}
#{else}
    No Entities match your key word
#{/else}

<br/><br/>

<h4>Entities by description</h4>
#{list items:entityByKeyResult, as:'product'}
    
#{if !(product.organization.isSecret()) || product.organization.isMember(id)}
   <a href = @{Browse.viewEntity(product.id)} class="standardLink"> ${product.name}</a><br/>
#{/if}
#{/list}
#{else}
    No entities have this description
#{/else}

<br/><br/>

<h4>Plans by title</h4>
#{list items:planByTitleResult, as:'product'}
    
#{if !(false)}
   <a href = @{Application.showPlan(product.id)} class="standardLink"> ${product.title}</a><br/>
#{/if}
#{else}
     secret : ${product.title} <br>
#{/else}
#{/list}
#{else}
    No plans have this title
#{/else}

<br/><br/>

<h4>Topics by name</h4>
#{list items:topicByNameResult, as:'product'}
    
#{if !(product.status == 3) && (!(product.entity.organization.isSecret()) || product.entity.organization.isMember(id))}
   <a href = @{Browse.viewTopic(product.id)} class="standardLink"> ${product.name}</a><br/>
#{/if}

#{/list}
#{else}
    No topics match your key word
#{/else}
<br/><br/>

<h4>Topics by tag</h4>
#{list items:topicByTagResult, as:'product'}
    
#{if !(product.status == 3) && (!(product.entity.organization.isSecret()) || product.entity.organization.isMember(id))}
   <a href = @{Browse.viewTopic(product.id)} class="standardLink"> ${product.name}</a><br/>
#{/if}
#{else}
     secret : ${product.name} <br>
#{/else}
#{/list}
#{else}
    No topics related to your key word
#{/else}
<br/><br/><br/>
<a href="@{Export.exportCSV(searchKeyWord)}">Export Results as CSV file.</a>
